package com.niit.onlinemusicserver34.controller;

import com.niit.onlinemusicserver34.common.R;
import com.niit.onlinemusicserver34.model.request.AdminRequest;
import com.niit.onlinemusicserver34.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

//@Controller      // 所有的hanlder方法默认返回的视图的名称
@RestController    // 所有的hanlder方法默认返回的都是json
@RequestMapping("/admin") // 可选的
public class AdminController {

    // DI Dependency Injection 依赖注入
    // IoC Inverse of Controller 控制翻转  容器 Container 体现beans.xml配置/@Bean注解
    @Autowired  // 自动装配/自动注入
    AdminService  adminService;

    // 判断是否登录成功
    @PostMapping("/login/status") // http协议 报文的body部分
    public R loginStatus(@RequestBody AdminRequest adminRequest, HttpSession session) {
        R result = adminService.verifyPasswd(adminRequest, session);
        return result;
    }
}
